﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/WithoutPermBasic.Master" AutoEventWireup="true" CodeBehind="BottleQueryScan.aspx.cs" Inherits="PMS.UI.PM.BottleQueryScan" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        var LabelUrl;
        var CertificateUrl;
        $(function () {
            var rowData;
            var height = $("#divTotal").height();
            var content = parseFloat(height) - 60;
            $("#tbList").css("height", content);

            $("#SweepCode").focus();
            //Jquery监听扫码枪回车事件
            $("#SweepCode").keyup(function (event) {
                if (event.keyCode == 13) {
                    var code = $(this).val();
                    code = code.replace(/\n/g, "")
                    $(this).val("");
                    LoadTable("", code)
                }
            });
            //通过分析模块内部进入，传了ID
            var id = com.get.ID;
            if (id != undefined) {
                LoadTable(id, "")
            }
        });
    </script>
    <script type="text/javascript">
        function LoadTable(id, barCode) {
            //根据气瓶状态设置按钮权限
            var action = com.get.action;

            if (action == "view") {

            }

            $.ajax({
                type: "POST",
                dataType: "json",
                url: "/Logic/PM/BottleProductionAjax.aspx?method=GetBottleTrackingByIDCode",
                data: { 'ID': id, 'BarCode': barCode },
                success: function (data) {
                    $("#form1").form("load", data);
                    LabelUrl = data.LabelUrl;
                    CertificateUrl = data.CetificateUrl;
                }
            });

            $("#tbList").datagrid({
                url: '/Logic/PM/BottleAnalyseAjax.aspx?method=GetBottleAnalyseRes',
                queryParams: { 'ID': id, 'BarCode': barCode },
                loadMsg: '数据加载中请稍后……',
                rownumbers: true,
                idField: "ID",
                lines: true,
                // fitColumns:true,
                columns: [[
                    {
                        field: 'ck', checkbox: true, width: 30
                    },
                    {
                        field: 'InputGroup', title: '组别', align: "center", width: 50
                    },
                    {
                        field: 'GasChiName', title: '气体名称', width: 80, align: "center"
                    },
                    {
                        field: 'GasEngName', title: '分子式', width: 100, align: "center"
                    },
                     {
                         field: 'BudgetConcentration', title: '客户浓度(ppm)', width: 100, align: "center",
                         formatter: function (value, row, index) {
                             return (value * 10000).toFixed(2);
                         }
                     },
                     {
                         field: 'CusConcUnit', title: '客户带单位浓度', width: 100, align: "center"
                     },
                      {
                          field: 'Tolerance', title: '误差容忍度(ppm)', align: "center", width: 100
                      },
                    {
                        field: 'Concentration', title: '计算浓度(ppm)', width: 100, align: "center",
                        formatter: function (value, row, index) {
                            return (value * 10000).toFixed(2);
                        }
                    },

                    {
                        field: 'AnalyseConcentration', title: '分析浓度(ppm)', width: 100, align: "center",
                        formatter: function (value, row, index) {
                            if (value == null) value = 0;
                            return (value * 10000).toFixed(2);
                        }
                    },
                    { field: 'TotalWeight', title: '总重(g)', align: "center", width: 80 },
                      {
                          field: 'SingleWeight', title: '样气质量', align: "center", width: 80
                      },
                       {
                           field: 'GasWeight', title: '分子量', width: 60, align: "center"
                       },
                       {
                           field: 'SampleVolume', title: '样气量', align: "center", width: 80
                       },
                        //{
                        //    field: 'BudgetConcentration', title: '预算浓度', align: "center",
                        //    formatter: function (value, row, index) {
                        //        return value / 10000 + "%";
                        //    }
                        //},
                         {
                             field: 'BudgetWeight', title: '预算克数', align: "center", width: 80
                         },
                         {
                             field: 'OneConcentration', title: '一次气浓度(%)', align: "center", width: 85
                         },
                         {
                             field: 'OneBottleCode', title: '一次气瓶号', align: "center", width: 85
                         },
                         {
                             field: 'BudgetPressure', title: '预算压力(MPa)', align: "center", width: 85
                         },
                          {
                              field: 'IsBottom', title: '是否底气', align: "center",
                              formatter: function (value, row, index) {
                                  if (value == "0") {
                                      return "否";
                                  }
                                  else {
                                      return "是";
                                  }
                              }
                          },
                           {
                               field: 'IsComplete', title: '是否完成', align: "center", formatter: function (value, row, index) {
                                   if (value == "0") {
                                       return "未开始";
                                   }
                                   else if (value == "1") {
                                       return "已完成";
                                   }

                               }
                           },

                    {
                        field: 'AnalyseMethod', title: '分析方法', width: 180, align: "center",
                        formatter: function (value, row, index) {
                            if (value == null) value = "";
                            return value;
                        }
                    },
                    {
                        field: 'AnalStandardConc', title: '标准气浓度(%)', width: 85, align: "center",
                        formatter: function (value, row, index) {
                            if (value == null) value = "0";
                            return value;
                        }
                    },
                    {
                        field: 'AnalStandardBottleCode', title: '标准气瓶号', width: 85, align: "center",
                        formatter: function (value, row, index) {
                            if (value == null) value = "";
                            return value;
                        }
                    },
                    {
                        field: 'AnalyseFile', title: '分析文件名称', width: 100, align: "center",
                        formatter: function (value, row, index) {
                            if (value == null) value = "";
                            return value;
                        }
                    },
                     {
                         field: 'PrintUnit', title: '打印单位', width: 80, align: "center",
                         formatter: function (value, row, index) {
                             if (value == null) value = '0';
                             if (value == "0") {
                                 return "mol/mol";
                             }
                             else if (value == "1") {
                                 return "mg/m3";
                             }
                         }
                     },
                      {
                          field: 'PrintConcentration', title: '打印浓度', width: 90, align: "center",
                          formatter: function (value, row, index) {
                              if (value == null) value = '1';
                              if (value == "0") {
                                  return "计算浓度";
                              }
                              else if (value == "1") {
                                  return "分析浓度";
                              }
                          }
                      },
                      {
                          field: 'PrintDigitNum', title: '打印位数', width: 60, align: "center",
                          formatter: function (value, row, index) {
                              if (value == null) value = '3';
                              return value;
                          }
                      },

                    {
                        field: 'AnalyseNote', title: '备注', sortable: false, width: 100, align: "center"
                    },
                ]],
                singleSelect: true,
                striped: true,
                onLoadSuccess: function () {
                    com.mergeCells("tbList", "InputGroup")
                }
            });
        }

    </script>
    <script>
        //打印标签
        function funcPrintLabel(temp) {
            var analRes = $('#AnalyseRes').combobox('getValue');
            if (analRes == '2' || analRes == undefined) {
                com.message('error', '当前气瓶还未分析完成，无法打印');
                return;
            }

            if (analRes == '1') {
                com.message('error', '当前气瓶分析结果为不合格，无法打印标签');
                return;
            }

            var Id = $('#ID').val();
            switch (temp) {
                case 1:
                    top.wrapper.addTab("打印标签", "/UI/PM/PrintLabel.aspx?action=print&Id=" + Id);
                    break;
                case 2:
                    top.wrapper.addTab("打印标签", "/UI/PM/PrintLabel2.aspx?action=print&Id=" + Id);
                    break;
                case 3:
                    top.wrapper.addTab("打印标签", "/UI/PM/PrintLabel3.aspx?action=print&Id=" + Id);
                    break;
                case 4:
                    top.wrapper.addTab("打印标签", "/UI/PM/PrintLabel4.aspx?action=print&Id=" + Id);
                    break;
                case 5:
                    top.wrapper.addTab("打印标签", "/UI/PM/PrintLabel5.aspx?action=print&Id=" + Id);
                    break;
                default:
            }

        }
        //打印记录
        function funcPrintRecord(temp) {
            //var Id = com.get.ID
            //if (Id == undefined) {
            //    Id = $('#ID').val();
            //}
            var Id = $('#ID').val();
            switch (temp) {
                case 1:
                    if (LabelUrl != null && LabelUrl != "") {
                        top.wrapper.addTab("标签记录", "/UI/PM/" + LabelUrl + ".aspx?action=record&Id=" + Id);
                    }
                    else {
                        com.message('error', '当前气体暂无打印记录！');
                    }

                    break;
                case 2:
                    if (CertificateUrl != null && CertificateUrl != "") {
                        top.wrapper.addTab("证书记录", "/UI/PM/" + CertificateUrl + ".aspx?action=record&Id=" + Id);
                    }
                    else {
                        com.message('error', '当前气体暂无打印记录！');
                    }

                    break;
                default:
            }
        }

        //打印证书
        function funcPrintCert() {
            var analRes = $('#AnalyseRes').combobox('getValue');
            if (analRes == '2' || analRes == undefined) {
                com.message('error', '当前气瓶还未分析完成，无法打印');
                return;
            }

            if (analRes == '1') {
                com.message('error', '当前气瓶分析结果为不合格，无法打印证书');
                return;
            }

            //var Id = com.get.ID
            //if (Id == undefined) {
            //    Id = $('#ID').val();
            //}
            var Id = $('#ID').val();
            top.wrapper.addTab("打印国标气体", "/UI/PM/PrintCertificate.aspx?Id=" + Id)
        }

        function funcPrintCertPure() {
            var analRes = $('#AnalyseRes').combobox('getValue');
            if (analRes == '2' || analRes == undefined) {
                com.message('error', '当前气瓶还未分析完成，请判定是否合格后再打印');
                return;
            }

            if (analRes == '1') {
                com.message('error', '当前气瓶分析结果为不合格，无法打印证书');
                return;
            }
            //var Id = com.get.ID
            //if (Id == undefined) {
            //    Id = $('#ID').val();
            //}
            var Id = $('#ID').val();
            top.wrapper.addTab("打印非国标气体", "/UI/PM/PrintCertificatePure.aspx?Id=" + Id)
        }

        function funcPrintCertOxygen() {
            var analRes = $('#AnalyseRes').combobox('getValue');
            if (analRes == '2' || analRes == undefined) {
                com.message('error', '当前气瓶还未分析完成，请判定是否合格后再打印');
                return;
            }

            if (analRes == '1') {
                com.message('error', '当前气瓶分析结果为不合格，无法打印证书');
                return;
            }
            //var Id = com.get.ID
            //if (Id == undefined) {
            //    Id = $('#ID').val();
            //}
            var Id = $('#ID').val();
            top.wrapper.addTab("打印国标气体", "/UI/PM/PrintCertificateOxygen.aspx?Id=" + Id)
        }

    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceToorbar" runat="server">
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <div style="height: 100%; overflow: auto">
        <div id="master" class="container_12" style="height: auto;">
            <form id="form1">
                <div class="grid_12 val" style="height: 50px; text-align: center;">
                    <textarea id="SweepCode" name="Note" style="width: 800px; height: 40px" placeholder="该区域是扫码区域，需要获取鼠标焦点，即可扫码"></textarea>
                </div>
                <div class="clear"></div>
                <div class="grid_3 sealbl" style="text-align: right;">
                    流水号 :
                    <input type="text" id="SerialCode" name="SerialCode" />
                </div>
                <div class="grid_3 sealbl" style="text-align: right;">
                    气瓶编号 :
                    <input type="text" id="BottleCode" name="BottleCode" />
                </div>

                <div class="grid_3 sealbl" style="text-align: right;">
                    生产单号 :
                    <input type="text" id="ProductOrderCode" name="ProductOrderCode"  />
                </div>

                <div class="grid_3 sealbl" style="text-align: right;">
                    客户名称 :
                    <input type="text" id="CustomerName" name="CustomerName"  />
                </div>
                 <div class="clear"></div>
                 <div class="grid_12 val" style="height: 10px; text-align: center;"></div>
                <div class="grid_3 sealbl" style="text-align: right;">
                    气瓶状态 :
                    <input type="text" class="easyui-combobox" id="State" name="State" disabled="disabled" 
                        data-options="valueField:'value',textField:'text',data:StaticCombo.BottleState,panelHeight:'auto', editable:false" />
                </div>
                 <div class="grid_3 sealbl" style="text-align: right;">
                    打印状态 :
                    <input type="text" class="easyui-combobox" id="PrintState" name="PrintState" disabled="disabled" 
                        data-options="valueField:'value',textField:'text',data:StaticCombo.PrintState,panelHeight:'auto', editable:false" />
                </div>
                <div class="grid_3 sealbl" style="text-align: right;">
                    产品名称 :
                    <input type="text" id="ProductName" name="ProductName"  />
                </div>

                 <div class="grid_3 sealbl" style="text-align: right;">
                    投产日期:
                    <input type="text" id="FillDate" name="FillDate" disabled="disabled" />
                </div>
                <div class="clear"></div>
                <div class="grid_12 val" style="height: 10px; text-align: center;"></div>
                <div class="grid_3 sealbl" style="text-align: right;">
                    配气日期:
                    <input type="text" id="CompletedDate" name="CompletedDate" disabled="disabled" />
                </div>
                <div class="grid_3 sealbl" style="text-align: right;">
                    分析日期:
                    <input type="text" id="AnalyseDate" name="AnalyseDate" disabled="disabled" />
                </div>
                <div class="grid_3 sealbl" style="text-align: right;">
                    入库日期:
                    <input type="text" id="InStorageDate" name="InStorageDate" disabled="disabled" />
                </div>
                <div class="grid_3 sealbl" style="text-align: right;">
                    发货日期:
                    <input type="text" id="DeliveryDate" name="DeliveryDate" disabled="disabled" />
                </div>
                <div class="clear"></div>
                <div class="grid_12 val" style="height: 10px; text-align: center;"></div>
                 <div class="grid_3 sealbl" style="text-align: right;">
                    分析结论:
                    <input type="text" class="easyui-combobox" id="AnalyseRes" name="AnalyseRes" disabled="disabled" data-options="valueField:'value',textField:'text',data:StaticCombo.BottleAnalyseRes,panelHeight:'auto'" />
                </div>
                 <div class="grid_3 sealbl" style="text-align: right;">
                    空瓶重 :
                     <input type="text" id="EmptyBottleWeight" name="EmptyBottleWeight" class="easyui-numberbox" data-options="min:0,precision:3,editable:false" />
                </div>

                <div class="grid_3 sealbl" style="text-align: right;">
                    预算压力 : 
                    <input type="text" id="BudgetPressure" name="BudgetPressure" class="easyui-numberbox" data-options="min:0,precision:2,editable:false" />
                </div>

                <div class="grid_3 sealbl" style="text-align: right;">
                    总量:<input type="text" id="TotalNum" name="TotalNum" class="easyui-textbox" data-options="editable:false" />
                </div>
                <input type="hidden" id="ID" name="ID" />
                <div class="grid_12 val" style="height: 10px; text-align: center;"></div>
            </form>
        </div>
    </div>
    <div id="divTable" style="height: auto; width: 100%">
        <div id="divToobar" style="background-color: #EFEFEF; overflow: visible">
            <a href="javascript:void(0)" id="btnPrintLabel" class="easyui-menubutton"
                data-options="menu:'#MpShowLabel',iconCls:'icon-printer'">打印标签</a>

            &nbsp;&nbsp;
               <a href="javascript:void(0)" id="btnPrintCert" class="easyui-menubutton"
                   data-options="menu:'#MpShow',iconCls:'icon-printer'">打印证书</a>

            &nbsp;&nbsp;
               <a href="javascript:void(0)" id="btnPrintRecord" class="easyui-menubutton"
                   data-options="menu:'#MpRecord',iconCls:'icon-printer'">打印记录</a>
        </div>


        <div id="MpShow" style="width: 120px;">


            <div data-options="iconCls:'icon-script_start'" onclick="funcPrintCert()">国标</div>
            <div class="menu-sep"></div>
            <div data-options="iconCls:'icon-script_start'" onclick="funcPrintCertPure()">非国标</div>
            <div class="menu-sep"></div>
            <div data-options="iconCls:'icon-script_start'" onclick="funcPrintCertOxygen()">20.8氧气</div>

        </div>

        <div id="MpShowLabel" style="width: 120px;">


            <div data-options="iconCls:'icon-script_start'" onclick="funcPrintLabel(1)">聚光标签</div>
            <div class="menu-sep"></div>
            <div data-options="iconCls:'icon-script_start'" onclick="funcPrintLabel(2)">亦恒标签</div>
            <div class="menu-sep"></div>
            <div data-options="iconCls:'icon-script_start'" onclick="funcPrintLabel(3)">普通标签</div>
            <div class="menu-sep"></div>
            <div data-options="iconCls:'icon-script_start'" onclick="funcPrintLabel(4)">20.8氧气标签</div>
            <div class="menu-sep"></div>
            <div data-options="iconCls:'icon-script_start'" onclick="funcPrintLabel(5)">中文名称标签</div>
        </div>

        <div id="MpRecord" style="width: 120px;">


            <div data-options="iconCls:'icon-script_start'" onclick="funcPrintRecord(1)">标签记录</div>
            <div class="menu-sep"></div>
            <div data-options="iconCls:'icon-script_start'" onclick="funcPrintRecord(2)">证书记录</div>


        </div>
        <table id="tbList" title="气瓶气体信息" style="height: auto; width: 100%; margin: 0 auto"></table>
    </div>
</asp:Content>

